export default {
  // 驼峰转换  RO_NO --> roNo
  camelCase(str) {
    let arr = str.split('_');
    let upper = arr.map((val, index) => {
      let lowStr = val.toLowerCase();
      if (index) {
        lowStr = lowStr.charAt(0).toLocaleUpperCase() + lowStr.slice(1);
      }
      return lowStr;
    });
    return upper.join('');
  },
  // {对象} 所有字段转驼峰
  camelCaseObject(obj) {
    const newObj = {};
    const keys = Object.keys(obj);
    keys.forEach((key, i) => {
      newObj[this.camelCase(key)] = obj[key];
    });
    return newObj;
  }
};
